package com.example.ordersystem.service;


import com.example.ordersystem.dao.OrderDAOByMybatis;
import com.example.ordersystem.domain.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {
    @Autowired
    OrderDAOByMybatis orderDAOByMybatis;

    public void addOrder(Order order) {
        orderDAOByMybatis.addOrder(order);
    }

    /**
     * 根据顾客编号查询订单
     * @param customer 顾客编号
     * @return 顾客的所有订单
     */
    public List<Order> findByCustomer(int customer){
        return orderDAOByMybatis.findByCustomer(customer);
    }


    public void deleteByNum(String num) {
        orderDAOByMybatis.deleteOrderByNum(num);
    }

    public List<Order> findAllOrder() {
        return orderDAOByMybatis.findAllOrder();
    }

    public List<Order> findBetweenAnd(String begin, String end) {
        return orderDAOByMybatis.findBetweenAnd(begin, end);
    }

    /**
     * 根据订单编号,更新订单状态
     * @param orderNum 订单编号
     * @param status 订单状态
     */
    public void updateStatusByNum(String orderNum, String status) {
        orderDAOByMybatis.updateStatusByNum(orderNum,status);
    }

}
